<?php
namespace App\Http\Controllers;

use App\Models\Live;
use Illuminate\Support\Facades\Schema;

class LiveController extends WxBaseController{
    protected $except=['index','show'];
    public function index($num=10,$order='created_at'){
        $lives = Live::orderBy($order,'desc')->simplePaginate($num);
        editImageUrl($lives);
        return $this->apiReturn(true,'success',$lives);
    }
    public function show($id){
        $live = Live::where('id',$id);
        //更新浏览量
        if(Schema::hasColumn('lives', 'watch')){
            $live->increment('watch');
        };
        $arr=$live->get();
        editImageUrl($arr);
        return $this->apiReturn(true,'success',$arr);
    }
}